#include "friendsitem.h"
#include "ui_friendsitem.h"
#include <QImage>
#include <QPixmap>

friendsitem::friendsitem(int curent_id,const QString &name ,const QString &avatarUrl,QWidget *parent)
    : QWidget(parent),id(curent_id),friendname(name),avatar_url(avatarUrl)
    , ui(new Ui::friendsitem)
{
    file_request = new FileRequest(this);
    ui->setupUi(this);
    ui->label_2->setText(name);
    file_request->getFile(avatarUrl);
    connect(file_request,&FileRequest::getFinished,this,&friendsitem::onFileGetFinished);
}

friendsitem::~friendsitem()
{
    delete ui;
}

void friendsitem::onFileGetFinished(QByteArray data)
{
    QPixmap pix;
    pix.loadFromData(data);
    ui->label->setPixmap(pix);
}

